// utils/mockData.js - 模拟数据用于本地测试

// 模拟用户数据
const mockUsers = [
  {
    id: '1001',
    nickname: '小可爱',
    age: 24,
    gender: 'female',
    city: '北京',
    avatar_url: 'https://via.placeholder.com/150x150?text=用户1',
    introduction: '喜欢旅行和美食，希望遇见有趣的灵魂',
    tags: ['旅行', '美食', '摄影'],
    photos: [
      'https://via.placeholder.com/300x300?text=照片1',
      'https://via.placeholder.com/300x300?text=照片2'
    ],
    distance: 1.2,
    last_active_time: '刚刚活跃'
  },
  {
    id: '1002',
    nickname: '阳光男孩',
    age: 26,
    gender: 'male',
    city: '上海',
    avatar_url: 'https://via.placeholder.com/150x150?text=用户2',
    introduction: '热爱运动，喜欢篮球和健身',
    tags: ['运动', '篮球', '健身'],
    photos: [
      'https://via.placeholder.com/300x300?text=照片1'
    ],
    distance: 2.5,
    last_active_time: '10分钟前'
  },
  {
    id: '1003',
    nickname: '文艺青年',
    age: 25,
    gender: 'female',
    city: '杭州',
    avatar_url: 'https://via.placeholder.com/150x150?text=用户3',
    introduction: '喜欢读书和音乐，寻找志同道合的朋友',
    tags: ['读书', '音乐', '电影'],
    photos: [
      'https://via.placeholder.com/300x300?text=照片1',
      'https://via.placeholder.com/300x300?text=照片2',
      'https://via.placeholder.com/300x300?text=照片3'
    ],
    distance: 3.8,
    last_active_time: '1小时前'
  }
];

// 模拟对话数据
const mockConversations = [
  {
    id: 'conv1',
    partner_id: '1001',
    partner_name: '小可爱',
    partner_avatar: 'https://via.placeholder.com/150x150?text=用户1',
    last_message: '你好呀，很高兴认识你！',
    last_message_time: '10:30',
    unread_count: 2,
    partner_online: true
  },
  {
    id: 'conv2',
    partner_id: '1002',
    partner_name: '阳光男孩',
    partner_avatar: 'https://via.placeholder.com/150x150?text=用户2',
    last_message: '周末有空一起打球吗？',
    last_message_time: '昨天',
    unread_count: 0,
    partner_online: false
  }
];

// 模拟消息数据
const mockMessages = {
  conv1: [
    {
      id: 'msg1',
      conversation_id: 'conv1',
      sender_id: '1001',
      content: '你好呀，很高兴认识你！',
      type: 'text',
      timestamp: '10:25',
      is_read: true
    },
    {
      id: 'msg2',
      conversation_id: 'conv1',
      sender_id: 'user_current',
      content: '我也很高兴认识你！',
      type: 'text',
      timestamp: '10:28',
      is_read: true
    },
    {
      id: 'msg3',
      conversation_id: 'conv1',
      sender_id: '1001',
      content: '你平时喜欢做什么呀？',
      type: 'text',
      timestamp: '10:30',
      is_read: false
    }
  ]
};

// 模拟API响应
const mockApiResponses = {
  // 登录响应
  login: {
    success: true,
    data: {
      token: 'mock_token_123456',
      user: {
        id: 'user_current',
        nickname: '测试用户',
        avatar_url: 'https://via.placeholder.com/150x150?text=当前用户',
        age: 25,
        city: '北京',
        gender: 'male'
      }
    }
  },

  // 推荐用户响应
  recommend: {
    success: true,
    data: {
      matches: mockUsers,
      has_more: false
    }
  },

  // 喜欢用户响应
  like: {
    success: true,
    data: {
      is_match: Math.random() > 0.7 // 30%概率匹配成功
    }
  },

  // 对话列表响应
  conversations: {
    success: true,
    data: {
      conversations: mockConversations
    }
  },

  // 消息列表响应
  messages: {
    success: true,
    data: {
      messages: mockMessages.conv1
    }
  }
};

// 模拟API调用
function mockApiCall(apiName, data = null) {
  return new Promise((resolve) => {
    setTimeout(() => {
      const response = mockApiResponses[apiName];
      if (response) {
        resolve({ data: response });
      } else {
        resolve({ 
          data: { 
            success: false, 
            message: 'API不存在' 
          } 
        });
      }
    }, 500); // 模拟网络延迟
  });
}

// 导出模拟数据和方法
module.exports = {
  mockUsers,
  mockConversations,
  mockMessages,
  mockApiCall
};
